package com.masterclient.app.modules.cart.holder;

import android.support.v4.app.Fragment;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.alibaba.android.arouter.launcher.ARouter;
import com.masterclient.app.App;
import com.masterclient.app.R;
import com.eoner.managerlibrary.router.AroutePath;
import com.masterclient.app.base.FragmentHostActivity;
import com.masterclient.app.modules.cart.adapter.ShopCartAdapterListener;
import com.masterclient.app.modules.cart.beans.PromotionsItemBean;

public class ActivityHeadHolder extends RecyclerView.ViewHolder implements View.OnClickListener {

    private PromotionsItemBean promotionsItemBean;

    private LinearLayout ll_item;
    private TextView tvActivityName;
    private TextView tvActivityDes;

    public ActivityHeadHolder(ViewGroup itemView, ShopCartAdapterListener listener) {
        super(LayoutInflater.from(itemView.getContext()).inflate(R.layout.view_item_cart_mj_head, itemView, false));

        ll_item = this.itemView.findViewById(R.id.ll_item);
        tvActivityName = this.itemView.findViewById(R.id.tv_activity_name);
        tvActivityDes = this.itemView.findViewById(R.id.tv_activity_des);
        ll_item.setOnClickListener(this);
    }

    public void onBindViewHolder(PromotionsItemBean itemBean) {
        promotionsItemBean = itemBean;
        tvActivityName.setText(promotionsItemBean.labelName);
        tvActivityDes.setText(promotionsItemBean.activityName);
    }

    @Override
    public void onClick(View view) {
        if (view.getId() == R.id.ll_item) {
            Fragment fragment = (Fragment) ARouter.getInstance().build(AroutePath.GATHER_GOODS_FRAGMENT)
                    .withString("activityId", promotionsItemBean.activityId)
                    .navigation();
            FragmentHostActivity.openFragment(App.getContext(), fragment);
        }
    }
}
